package com.czy.contorller.user;

import com.czy.dto.UserCheckinDto;
import com.czy.result.Result;
import com.czy.service.CheckinRecordService;
import com.czy.vo.CaptchaVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/user/sign")
public class CheckinRecordController {

    @Autowired
    private CheckinRecordService recordService;


    // 生产验证码
    @GetMapping("/verificationCode")
    public Result<CaptchaVo> RandomCaptcha() {
        CaptchaVo vo =  recordService.randomNum();
        log.info("生产的随机验证码：{}" ,vo);
        return Result.success(vo);
    }

    //新增签到信息

    @PostMapping("/signIn")
    public Result addCheckin(@RequestBody UserCheckinDto userCheckinDto){
        log.info("签到用户信息：{}" , userCheckinDto);
        recordService.insertCheckin(userCheckinDto);
        return Result.success();
    }
}
